<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=0, viewport-fit=cover" />
	<title>call</title>
</head>
<body>
<script>


var test = function (num1, num2) {
	console.log(this);
	return num1 + num2
}


Function.prototype._call = function (ctx, ...args) {
	if (typeof ctx !== 'object') throw new Error('您传进来的 ctx 实参不是一个对象')
	ctx = ctx || window;
	if (typeof this !== 'function') throw new Error('this 不是一个方法')

	ctx.fn = this
	const result = ctx.fn(...args)

	delete ctx.fn;

	return result;
};

const result = test._call({ name: 'wgm' }, 1, 2)
console.log(result)


</script>
</body>
</html>
